import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 模具信息信息 */
export interface Info {
  id: number // 模具id
  drawingNo?: string // 图号
  code: string // 编码
  categoryId?: number // 类型id
  customer: string // 客户名
  description: string // 描述
}

// 模具信息 API
export const InfoApi = {
  // 查询所有停线类型
  getCategoryAll: async () => {
    return await request.get({ url: `/mold/category/getAll` })
  },

  // 查询模具信息分页
  getInfoPage: async (params: any) => {
    return await request.get({ url: `/mold/info/page`, params })
  },

  // 查询模具信息详情
  getInfo: async (id: number) => {
    return await request.get({ url: `/mold/info/get?id=` + id })
  },

  // 新增模具信息
  createInfo: async (data: Info) => {
    return await request.post({ url: `/mold/info/create`, data })
  },

  // 修改模具信息
  updateInfo: async (data: Info) => {
    return await request.put({ url: `/mold/info/update`, data })
  },

  // 删除模具信息
  deleteInfo: async (id: number) => {
    return await request.delete({ url: `/mold/info/delete?id=` + id })
  },

  /** 批量删除模具信息 */
  deleteInfoList: async (ids: number[]) => {
    return await request.delete({ url: `/mold/info/delete-list?ids=${ids.join(',')}` })
  },

  // 导出模具信息 Excel
  exportInfo: async (params) => {
    return await request.download({ url: `/mold/info/export-excel`, params })
  }
}
